﻿using MediatR;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.BodySizeHandler
{

    public class BodySizeListHandler : IRequestHandler<BodySizeListCommand, Results<PageOutput<BodySize>>>
    {
        private readonly IBodySizeService service;

        public BodySizeListHandler(IBodySizeService service)
        {
            this.service = service;
        }

        public async Task<Results<PageOutput<BodySize>>> Handle(BodySizeListCommand request, CancellationToken cancellationToken)
        {
            return Results<PageOutput<BodySize>>.DataResult(await service.GetBodySize(request.overBit, request.SheepType, request.BodySex,request.pageIndex, request.pageSize));
        }
    }
}
